package cn.edu.zust.userservice.controller;

import Video.Dto.Video;
import cn.edu.zust.userservice.mapper.UserMapper;
import cn.edu.zust.userservice.mapper.VideoClient;
import cn.edu.zust.userservice.service.Impl.UserServiceImpl;
import cn.edu.zust.userservice.service.UsrService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.Result;

import java.util.List;


@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    VideoClient videoClient;
    @Autowired
    UsrService usrService;

    @Autowired
    UserMapper userMapper;
    @GetMapping("/{id}")
    public String getAccountById(@PathVariable("id") int id){
        return userMapper.getAccountById(id);
    }

    @GetMapping("/getAccountById/{account}")
    public int getIdByAccount(@PathVariable String account){
        return userMapper.getIdByAccount(account);
    }

    @GetMapping("/getAllVideos")
    Result<List<Video>> getAllVideos(){
        return videoClient.getAllVideos();
    }

    @GetMapping("/login/{account}")
    String getPasswordByAccount(@PathVariable("account") String account){
        return usrService.getPasswordByAccount(account);
    }
}
